﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StuManager
{
    public partial class FrmStudents : Form
    {
        public FrmStudents()
        {
            InitializeComponent();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            String name = txtUserName.Text;

            using (Context.MyContext ctx = new Context.MyContext())
            {
                var stus = ctx.Students.Where(s => s.StuName.Contains(name)).ToList();//ToList()直接查询出结果
                dataGridView1.DataSource = stus;
            }
        }
    }
}
